<html>
<head>
<title>WebOS</title>
</head>
<body id="body">
<script type="text/javascript" src="library/prototype.js"> </script>
<script type="text/javascript" src="library/window.js"> </script> 
<script type="text/javascript" src="library/window_ext.js"></script>
<script type="text/javascript" src="library/effects.js"></script>
<script type="text/javascript" src="library/window_effects.js"></script>
<script type="text/javascript" src="library/pwc-os.js"></script>
<link href="default.css" rel="stylesheet" type="text/css"/>
<link href="lighting.css" rel="stylesheet" type="text/css"/>
<link href="mac_os_x.css" rel="stylesheet" type="text/css"/>
<link href="sysmon.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">

function makeWindow(variable,height,width){
	new Ajax.PeriodicalUpdater(variable, '/api/' + variable +'',
	{
	method: 'get',
	frequency: 3,
	decay: 2,
	onSuccess: function(transport){
	}	
	});
  index = 0;
  var win = new Window({className: "mac_os_x", blurClassName: "blur_os_x", title: "window #"+index, width: width, height: height, top: 100 + index*50, left:100 + index*50}); 
	win.getContent().update('<h3><div id="' + variable + '"></div></h3>');
	win.setConstraint(true, {left:0, right:0, top: 0, bottom:0})
	win.setDestroyOnClose();
	win.show();
	index ++;
	 myObserver = {
    onClose: function(Event) {
	alert(win.getTitle() + " close");
	if(Windows.getFocusedWindow() == win){
	new Effect.Fade(win.taskbar, {afterFinish: function() {win.taskbar.remove()}});
	//win.taskbar.remove();
	//alert("bloop");
	} else {
	//alert("no bloop");
	}
  }
}
 // Windows.addObserver(taskbar);

    //Windows.windows.each( function(w) {alert("winID = " + w.getId());} );
}
</script>

<a href="javascript:makeWindow('system',150,300)">System Information</a>
<a href="javascript:makeWindow('uptime',30,400)">Uptime</a>
<a href="javascript:makeWindow('memory',175,310)">Memory</a>
<a href="javascript:makeWindow('time',300,500)">Time</a>

<div id="dock">    
</div>    
